Purpose

This document shows our analyses following the preregistered plan. It also shows the results of trimming all cases whose scores on either of the visual perception measures exceed 3 SDs from the pooled mean.

Setup

Analysis

Import

We import data previously cleaned using code_clean&visualization.Rmd.

# load the data and make each variable right
df1 <- readr::read_csv(file.path(params$data_path, params$csv_fn)) 
## 
## ── Column specification ────────────────────────────────────────────────────────
## cols(
##   Participant = col_double(),
##   Sex = col_character(),
##   motion_run = col_double(),
##   motion_shape = col_double(),
##   motion_scale = col_double(),
##   motion_thresh = col_double(),
##   motion_pcorr = col_double(),
##   contr_run = col_double(),
##   contr_shape = col_double(),
##   contr_scale = col_double(),
##   contr_thresh = col_double(),
##   contr_pcorr = col_double(),
##   Vocab_num_corr = col_double(),
##   Vocab_score = col_double(),
##   Mental_rot_score = col_double(),
##   Mental_rot_both = col_double(),
##   Feminine_hobbies = col_double(),
##   Masculine_hobbies = col_double()
## )

Examine outliers

Let’s detect outliers based on the criterion specified in params$outlier_sd_thresh.

But since we know we’re going to log-transform the visual scores, we’ll do the outlier detection in log space.

# define a function to remove outliers
FindOutliers <- function(data, sd_thresh = as.numeric(params$outlier_sd_thresh)) {
  sd = sd(data, na.rm = T)
  mean = mean(data, na.rm = T)
  # we identify extreme outliers
  extreme.threshold.upper = (sd * sd_thresh) + mean
  extreme.threshold.lower = -(sd * sd_thresh) + mean
  result <-
    which(data > extreme.threshold.upper |
            data < extreme.threshold.lower)
  print(result)
}

# Calculate indices (row numbers) of outliers for all measures.
# all_outliers <- lapply(df1[,-c('Participant', 'Sex', 'race', 'age', 'schoolyear',
#                                'handedness', 'glasses')], FindOutliers)
# all_outliers

motion_outliers <- FindOutliers(log(df1$motion_thresh))
##  [1]   85   86   87   88   93   94   95   96  269  270  271  272  553  554  555
## [16]  556  817  818  819  820 1117 1118 1119 1120 1145 1146 1147 1148 1401 1402
## [31] 1403 1853 1854 1855 1856 1945 1946 1947 1948 1949 1950 1951 1952 1993 1994
## [46] 1995 1996 1997 1998 1999 2000
contrast_outliers <- FindOutliers(log(df1$contr_thresh))
##  [1]   97  101  105  109  169  173  177  181  299  303  307  311  348  352  356
## [16]  360  506  510  514  518  762  766  770  774 1276 1280 1284 1288 1429 1433
## [31] 1773 1777 1781 1785 2002

Vision task outliers

df1 %>% 
  ggplot(.) +
  aes(y = motion_thresh, x = Sex) +
  geom_violin() +
  ggtitle('Motion thresholds by sex: All participants')
## Warning: Removed 16 rows containing non-finite values (stat_ydensity).

df1[-motion_outliers,] %>%
  ggplot(.) +
  aes(y = motion_thresh, x = Sex) +
  geom_violin() +
  ggtitle('Motion thresholds by sex: Excluding outliers')
## Warning: Removed 16 rows containing non-finite values (stat_ydensity).

By this criterion, we exclude 51 runs from \(n=\) 10, specifically participants: 104, 127, 338, 354, 374, 376, 393, 422, 428, 431.

Now, the contrast data.

df1 %>% 
  ggplot(.) +
  aes(y = contr_thresh, x = Sex) +
  geom_violin() +
  ggtitle('Contrast thresholds by sex: All participants')
## Warning: Removed 8 rows containing non-finite values (stat_ydensity).

df1[-contrast_outliers,] %>%
  ggplot(.) +
  aes(y = contr_thresh, x = Sex) +
  geom_violin() +
  ggtitle('Contrast thresholds by sex: Excluding outliers')
## Warning: Removed 8 rows containing non-finite values (stat_ydensity).

By this criterion, we exclude 35 runs from \(n=\) 10, specifically participants: 109, 117, 112, 116, 335, 351, 385, 395, 417, 114.

df2 <- df1[-c(contrast_outliers, motion_outliers),]

Check distributions

Do the data follow a normal distributions?

We use Shapiro-Wilk normality test, shapiro.test() and look at the normality plot.

The Shapiro-Wilk test can be performed as follows: - Null hypothesis: the data are normally distributed - Alternative hypothesis: the data are not normally distributed

# Shapiro-Wilk normality test

this_var <- c("Vocab_score",
             "Mental_rot_score",
             "Feminine_hobbies",
             "Masculine_hobbies",
             "Motion thresh",
             "Contrast thresh")

sw_stat <- c(shapiro.test(df2$Vocab_score)['statistic'],
             shapiro.test(df2$Mental_rot_score)['statistic'],
             shapiro.test(df2$Feminine_hobbies)['statistic'],
             shapiro.test(df2$Masculine_hobbies)['statistic'],
             shapiro.test(df2$motion_thresh)['statistic'],
             shapiro.test(df2$contr_thresh)['statistic']
             )

sw_p_val <- c(shapiro.test(df2$Vocab_score)['p.value'],
             shapiro.test(df2$Mental_rot_score)['p.value'],
             shapiro.test(df2$Feminine_hobbies)['p.value'],
             shapiro.test(df2$Masculine_hobbies)['p.value'],
             shapiro.test(df2$motion_thresh)['p.value'],
             shapiro.test(df2$contr_thresh)['p.value']
             )

shapiro_wilks_df <- tibble::tibble(this_var, sw_stat, sw_p_val)

shapiro_wilks_df %>%
  kableExtra::kable(., format = 'html') %>%
  kableExtra::kable_styling()
this_var sw_stat sw_p_val
Vocab_score 0.9791259 4.009707e-16
Mental_rot_score 0.9792548 4.559485e-16
Feminine_hobbies 0.979685 7.028962e-16
Masculine_hobbies 0.9923358 1.803463e-08
Motion thresh 0.8160343 2.747151e-42
Contrast thresh 0.7355752 5.33982e-48

The threshold measurements are especially non-normal.

T-test: Comparison between Sexes

Here is our pre-registered description of how we planned to compare sex differences:

To examine sex differences, one-tailed t tests will be conducted to compare men and women on 2 visual perception thresholds, spatial ability, and masculine hobbies. We will use verbal ability as our control variable. We set a family-wise Type I error rate at \(\alpha\)=0.05. Because there are four dependent variables hypothesized to show sex differences, the critical p value for each sex comparison is 0.0125 after Bonferroni correction. Our goal is to obtain .8 power to detect a medium effect size of .5 (Cohen’s \(d\)) at the \(p\) value of .0125 in the one-tailed t tests. Unequal sample sizes of the two sexes may be collected in this study. The minimum effect size of .50 can be obtained by at least 45 male participants out of a total sample size of 300 (see the R-code for power analysis at WRONG URL! shorturl.at/nDHLV). The minimum detectable effect size decreases when male and female sample sizes differ less, but to simply our \(t\) tests, we set the effect sizes at .5.

Transformation

If necessary, we will transform the psychophysical thresholds to make the distributions symmetric and appropriate for parametric analyses.

For vision task thresholds which are not normal (particularly for distributions that are right skewed), we will try the log transformation.

log(Motion duration threshold)

shapiro.test(log(df2$motion_thresh))
## 
##  Shapiro-Wilk normality test
## 
## data:  log(df2$motion_thresh)
## W = 0.94726, p-value < 2.2e-16
hist(log(df2$motion_thresh))

Even after the log transformation, Motion_duration_Threshold remains non-normal, but it is more symmetric.

mdt_tt <-
  t.test(
    log(df2$motion_thresh) ~ Sex,
    data = df2,
    var.equal = TRUE,
    alternative = "greater"
  ) #Hypothesized
mdt_tt
## 
##  Two Sample t-test
## 
## data:  log(df2$motion_thresh) by Sex
## t = 16.06, df = 1913, p-value < 2.2e-16
## alternative hypothesis: true difference in means is greater than 0
## 95 percent confidence interval:
##  0.1754005       Inf
## sample estimates:
## mean in group Females   mean in group Males 
##             -2.295497             -2.490922

We found there are sex differences in log(Motion_duration_Threshold). Males took significantly shorter time to detect the direction of the motion than females.

log(Contrast_Sensitivity_Threshold)

shapiro.test(log(df2$contr_thresh))
## 
##  Shapiro-Wilk normality test
## 
## data:  log(df2$contr_thresh)
## W = 0.8367, p-value < 2.2e-16
hist(log(df2$contr_thresh))

Contrast_Sensitivity_Threshold remains non-normal even after transformation.

t.test(
  log(df2$contr_thresh) ~ Sex,
  data = df2,
  var.equal = TRUE,
  alternative = "greater"
) #Hypothesized
## 
##  Two Sample t-test
## 
## data:  log(df2$contr_thresh) by Sex
## t = 6.7025, df = 1920, p-value = 1.342e-11
## alternative hypothesis: true difference in means is greater than 0
## 95 percent confidence interval:
##  0.06360246        Inf
## sample estimates:
## mean in group Females   mean in group Males 
##             -1.731374             -1.815674

Log transformed Contrast_Sensitivity_Threshold data show the predicted sex differences. Males detect the stimuli with lower contrast than females.

Power analysis

t_power <-
  pwr.t2n.test(
    n1 = 102 ,
    n2 = 30 ,
    d = NULL,
    sig.level = 0.0125,
    power = 0.8,
    alternative = "greater"
  )
t_power
## 
##      t test power calculation 
## 
##              n1 = 102
##              n2 = 30
##               d = 0.6465883
##       sig.level = 0.0125
##           power = 0.8
##     alternative = greater

We need \(|d|>0.65\) for a one-sided t test with \(p\) value of lower than 0.0125 and with power of 0.8.

Correlation within Sex

To examine how individual differences of visual perception measures are associated with other tasks, we will use correlations within sex. The lower visual perception threshold is, the higher perceptual sensitivity this individual has. In both sexes, we expect to find negative correlations between visual perception measures and spatial ability and masculine hobbies, but no significant correlation with verbal ability. There are four planned correlations (two visual perception tasks × two cognitive tasks) within sex, for a total of eight. This project is a novel study that has not to our knowledge been conducted previously. So we have consciously decided to maintain strict control of Type II error, in order to have enough statistical power to detect a small correlation effect sizes (r=0.20) within the constraints of sample size. This decision to maximize the power (.80) leads to a trade-off between Type I and Type II error. We plan to conduct eight separate one-tailed correlation tests with Type I error at 0.05 and no Bonferroni correction. With a critical p value of .05, around 150 participants are required for each group to detect an effect size of 0.20 at an obtained power of 0.8 with a one-tailed correlation test.

Overall

meets_criterion <- function(observed_p, criterion_p = .05/4) {
  if (observed_p <= criterion_p) {
    "meets"
  } else {
    "does not meet"
  }
}

Because our preregistration envisioned a much larger total sample, we have also chosen to report the overall correlations, combining males and females.

We select the variables for our correlation analysis, separate the two threshold measures, and make sure to log transform the threshold measures.

df_corr <- df2 %>%
  dplyr::arrange(., Participant) %>%
  dplyr::mutate(., log_motion_sens = log(motion_thresh),
                log_contrast_sens = log(contr_thresh)) 

df_corr_numeric <- df_corr %>%
  dplyr::select(., log_motion_sens,
                log_contrast_sens,
                Vocab_score,
                Mental_rot_score,
                Feminine_hobbies,
                Masculine_hobbies)
corr_all <- Hmisc::rcorr(as.matrix(df_corr_numeric), type = c("pearson"))

Coefficients

corr_all$r
##                   log_motion_sens log_contrast_sens  Vocab_score
## log_motion_sens         1.0000000        0.14539587 -0.152219793
## log_contrast_sens       0.1453959        1.00000000 -0.011920961
## Vocab_score            -0.1522198       -0.01192096  1.000000000
## Mental_rot_score       -0.1644018       -0.19574697 -0.005546707
## Feminine_hobbies        0.1799661        0.08674206 -0.119868300
## Masculine_hobbies      -0.2217621       -0.13128844  0.054957243
##                   Mental_rot_score Feminine_hobbies Masculine_hobbies
## log_motion_sens       -0.164401763       0.17996610       -0.22176205
## log_contrast_sens     -0.195746972       0.08674206       -0.13128844
## Vocab_score           -0.005546707      -0.11986830        0.05495724
## Mental_rot_score       1.000000000      -0.25911726        0.07489826
## Feminine_hobbies      -0.259117257       1.00000000        0.15163257
## Masculine_hobbies      0.074898260       0.15163257        1.00000000

P-values

corr_all$P
##                   log_motion_sens log_contrast_sens  Vocab_score
## log_motion_sens                NA      1.781491e-10 2.473799e-11
## log_contrast_sens    1.781491e-10                NA 6.025997e-01
## Vocab_score          2.473799e-11      6.025997e-01           NA
## Mental_rot_score     5.346834e-13      0.000000e+00 8.081902e-01
## Feminine_hobbies     2.664535e-15      1.472810e-04 1.400361e-07
## Masculine_hobbies    0.000000e+00      8.463499e-09 1.607971e-02
##                   Mental_rot_score Feminine_hobbies Masculine_hobbies
## log_motion_sens       5.346834e-13     2.664535e-15      0.000000e+00
## log_contrast_sens     0.000000e+00     1.472810e-04      8.463499e-09
## Vocab_score           8.081902e-01     1.400361e-07      1.607971e-02
## Mental_rot_score                NA     0.000000e+00      1.028397e-03
## Feminine_hobbies      0.000000e+00               NA      2.471534e-11
## Masculine_hobbies     1.028397e-03     2.471534e-11                NA
# Get some colors
col <- colorRampPalette(c("blue", "white", "red"))(20)
heatmap(x = corr_all$r, col = col, symm = TRUE)

Females

Select the females and focus on the numeric scores.

df_complete_F <- df_corr %>%
  dplyr::filter(., Sex == 'Females') 

df_corr_F <- df_complete_F %>%
  dplyr::select(., -Sex)

corr_F <- Hmisc::rcorr(as.matrix(df_corr_F), type = c("pearson"))

Coefficients

corr_F$r
##                     Participant    motion_run motion_shape motion_scale
## Participant        1.0000000000  0.0004247705  0.010510899 -0.003020930
## motion_run         0.0004247705  1.0000000000 -0.065108487 -0.069609436
## motion_shape       0.0105108990 -0.0651084866  1.000000000  0.890496752
## motion_scale      -0.0030209300 -0.0696094360  0.890496752  1.000000000
## motion_thresh     -0.0023342603 -0.0687473654  0.837204026  0.993045959
## motion_pcorr       0.0358642701  0.0505537727  0.206579433  0.365867244
## contr_run         -0.0040491753 -0.0004347500 -0.005376967 -0.001112705
## contr_shape        0.0052283426  0.0040156071  0.183961403  0.147567670
## contr_scale        0.0394061194  0.0048507288  0.158367200  0.132890416
## contr_thresh       0.0097093670  0.0058400827  0.135165816  0.113634053
## contr_pcorr        0.0220484212  0.0113752209 -0.100454359 -0.092578023
## Vocab_num_corr     0.0496230579 -0.0117896682 -0.105934420 -0.119136516
## Vocab_score        0.0384606105 -0.0087274829 -0.104383063 -0.123342451
## Mental_rot_score   0.1065598413 -0.0027279883 -0.167898650 -0.186164432
## Mental_rot_both    0.1336916898  0.0011297678 -0.184442982 -0.216493672
## Feminine_hobbies  -0.2258543221  0.0131145202  0.071569505  0.070662589
## Masculine_hobbies -0.1961182073  0.0207352255 -0.074799933 -0.093474709
## log_motion_sens   -0.0041957621 -0.0870266268  0.836426489  0.979607500
## log_contrast_sens  0.0028842363  0.0052199695  0.134382640  0.111791673
##                   motion_thresh  motion_pcorr     contr_run  contr_shape
## Participant       -2.334260e-03  0.0358642701 -4.049175e-03  0.005228343
## motion_run        -6.874737e-02  0.0505537727 -4.347500e-04  0.004015607
## motion_shape       8.372040e-01  0.2065794333 -5.376967e-03  0.183961403
## motion_scale       9.930460e-01  0.3658672437 -1.112705e-03  0.147567670
## motion_thresh      1.000000e+00  0.3869804222 -3.748706e-05  0.135350770
## motion_pcorr       3.869804e-01  1.0000000000 -4.760432e-04 -0.042582160
## contr_run         -3.748706e-05 -0.0004760432  1.000000e+00  0.041884497
## contr_shape        1.353508e-01 -0.0425821599  4.188450e-02  1.000000000
## contr_scale        1.226244e-01 -0.0244201553  3.650825e-02  0.933492013
## contr_thresh       1.042782e-01 -0.0359839873  5.355960e-02  0.771207400
## contr_pcorr       -8.743074e-02  0.0652754422 -8.531979e-02  0.122131607
## Vocab_num_corr    -1.196399e-01  0.0243538824  5.239029e-04  0.011564217
## Vocab_score       -1.253460e-01  0.0238399154  1.938062e-03 -0.002391065
## Mental_rot_score  -1.852922e-01  0.0398716609  3.783765e-03 -0.138160779
## Mental_rot_both   -2.172749e-01  0.0614468180 -1.341662e-03 -0.125792311
## Feminine_hobbies   6.919374e-02 -0.0579796091  2.244567e-03  0.050468407
## Masculine_hobbies -8.933989e-02 -0.0167622313 -9.432381e-03 -0.080018489
## log_motion_sens    9.795284e-01  0.3548552721 -4.326384e-04  0.145531629
## log_contrast_sens  1.023768e-01 -0.0447043643  4.512607e-02  0.752716276
##                    contr_scale contr_thresh  contr_pcorr Vocab_num_corr
## Participant        0.039406119  0.009709367  0.022048421   0.0496230579
## motion_run         0.004850729  0.005840083  0.011375221  -0.0117896682
## motion_shape       0.158367200  0.135165816 -0.100454359  -0.1059344196
## motion_scale       0.132890416  0.113634053 -0.092578023  -0.1191365161
## motion_thresh      0.122624410  0.104278212 -0.087430745  -0.1196399133
## motion_pcorr      -0.024420155 -0.035983987  0.065275442   0.0243538824
## contr_run          0.036508247  0.053559600 -0.085319785   0.0005239029
## contr_shape        0.933492013  0.771207400  0.122131607   0.0115642173
## contr_scale        1.000000000  0.831845681  0.248776848   0.0145530141
## contr_thresh       0.831845681  1.000000000  0.147037213   0.0414073361
## contr_pcorr        0.248776848  0.147037213  1.000000000   0.0510146548
## Vocab_num_corr     0.014553014  0.041407336  0.051014655   1.0000000000
## Vocab_score        0.004364094  0.014066295  0.062763660   0.9478095915
## Mental_rot_score  -0.128181565 -0.162823430  0.075551630   0.0081669413
## Mental_rot_both   -0.108533367 -0.151843461  0.111720626   0.0698675264
## Feminine_hobbies   0.027287627  0.009055546  0.009540034  -0.0757349917
## Masculine_hobbies -0.092147467 -0.095605196  0.029073782   0.0814194966
## log_motion_sens    0.130449156  0.112561106 -0.101272807  -0.1288069047
## log_contrast_sens  0.806715655  0.987757559  0.140261132   0.0520154613
##                    Vocab_score Mental_rot_score Mental_rot_both
## Participant        0.038460610      0.106559841     0.133691690
## motion_run        -0.008727483     -0.002727988     0.001129768
## motion_shape      -0.104383063     -0.167898650    -0.184442982
## motion_scale      -0.123342451     -0.186164432    -0.216493672
## motion_thresh     -0.125346018     -0.185292161    -0.217274865
## motion_pcorr       0.023839915      0.039871661     0.061446818
## contr_run          0.001938062      0.003783765    -0.001341662
## contr_shape       -0.002391065     -0.138160779    -0.125792311
## contr_scale        0.004364094     -0.128181565    -0.108533367
## contr_thresh       0.014066295     -0.162823430    -0.151843461
## contr_pcorr        0.062763660      0.075551630     0.111720626
## Vocab_num_corr     0.947809592      0.008166941     0.069867526
## Vocab_score        1.000000000      0.046890046     0.124693326
## Mental_rot_score   0.046890046      1.000000000     0.919035789
## Mental_rot_both    0.124693326      0.919035789     1.000000000
## Feminine_hobbies  -0.090905350     -0.304967086    -0.261746515
## Masculine_hobbies  0.036446906     -0.044150115    -0.044427448
## log_motion_sens   -0.132170045     -0.190045142    -0.227174451
## log_contrast_sens  0.021378096     -0.171913975    -0.155597347
##                   Feminine_hobbies Masculine_hobbies log_motion_sens
## Participant           -0.225854322      -0.196118207   -0.0041957621
## motion_run             0.013114520       0.020735226   -0.0870266268
## motion_shape           0.071569505      -0.074799933    0.8364264892
## motion_scale           0.070662589      -0.093474709    0.9796075000
## motion_thresh          0.069193743      -0.089339895    0.9795284201
## motion_pcorr          -0.057979609      -0.016762231    0.3548552721
## contr_run              0.002244567      -0.009432381   -0.0004326384
## contr_shape            0.050468407      -0.080018489    0.1455316288
## contr_scale            0.027287627      -0.092147467    0.1304491557
## contr_thresh           0.009055546      -0.095605196    0.1125611065
## contr_pcorr            0.009540034       0.029073782   -0.1012728068
## Vocab_num_corr        -0.075734992       0.081419497   -0.1288069047
## Vocab_score           -0.090905350       0.036446906   -0.1321700454
## Mental_rot_score      -0.304967086      -0.044150115   -0.1900451418
## Mental_rot_both       -0.261746515      -0.044427448   -0.2271744511
## Feminine_hobbies       1.000000000       0.495780084    0.0893209240
## Masculine_hobbies      0.495780084       1.000000000   -0.0975614332
## log_motion_sens        0.089320924      -0.097561433    1.0000000000
## log_contrast_sens      0.014793196      -0.091728638    0.1120984268
##                   log_contrast_sens
## Participant             0.002884236
## motion_run              0.005219970
## motion_shape            0.134382640
## motion_scale            0.111791673
## motion_thresh           0.102376816
## motion_pcorr           -0.044704364
## contr_run               0.045126067
## contr_shape             0.752716276
## contr_scale             0.806715655
## contr_thresh            0.987757559
## contr_pcorr             0.140261132
## Vocab_num_corr          0.052015461
## Vocab_score             0.021378096
## Mental_rot_score       -0.171913975
## Mental_rot_both        -0.155597347
## Feminine_hobbies        0.014793196
## Masculine_hobbies      -0.091728638
## log_motion_sens         0.112098427
## log_contrast_sens       1.000000000

P values

corr_F$P
##                    Participant   motion_run motion_shape motion_scale
## Participant                 NA 0.9870571894 6.881068e-01 9.081514e-01
## motion_run        9.870572e-01           NA 1.280472e-02 7.776211e-03
## motion_shape      6.881068e-01 0.0128047154           NA 0.000000e+00
## motion_scale      9.081514e-01 0.0077762106 0.000000e+00           NA
## motion_thresh     9.289657e-01 0.0085738717 0.000000e+00 0.000000e+00
## motion_pcorr      1.706530e-01 0.0533718770 1.554312e-15 0.000000e+00
## contr_run         8.768130e-01 0.9867895163 8.377396e-01 9.661975e-01
## contr_shape       8.413617e-01 0.8784481576 1.587175e-12 1.593844e-08
## contr_scale       1.312668e-01 0.8534304732 1.280492e-09 3.700522e-07
## contr_thresh      7.101153e-01 0.8239838558 2.321006e-07 1.412737e-05
## contr_pcorr       3.985817e-01 0.6648373630 1.252821e-04 4.101512e-04
## Vocab_num_corr    5.766478e-02 0.6538568653 5.336818e-05 5.433624e-06
## Vocab_score       1.413244e-01 0.7399363446 6.866417e-05 2.488616e-06
## Mental_rot_score  4.400594e-05 0.9173650090 1.264544e-10 9.139356e-13
## Mental_rot_both   2.835897e-07 0.9657267730 1.487255e-12 0.000000e+00
## Feminine_hobbies  0.000000e+00 0.6179171552 6.420611e-03 7.126681e-03
## Masculine_hobbies 3.685940e-14 0.4302843458 4.387775e-03 3.667585e-04
## log_motion_sens   8.726935e-01 0.0008687924 0.000000e+00 0.000000e+00
## log_contrast_sens 9.120809e-01 0.8424143889 2.727610e-07 1.945740e-05
##                   motion_thresh motion_pcorr   contr_run  contr_shape
## Participant        9.289657e-01 1.706530e-01 0.876812992 8.413617e-01
## motion_run         8.573872e-03 5.337188e-02 0.986789516 8.784482e-01
## motion_shape       0.000000e+00 1.554312e-15 0.837739641 1.587175e-12
## motion_scale       0.000000e+00 0.000000e+00 0.966197482 1.593844e-08
## motion_thresh                NA 0.000000e+00 0.998860852 2.233892e-07
## motion_pcorr       0.000000e+00           NA 0.985534898 1.046972e-01
## contr_run          9.988609e-01 9.855349e-01          NA 1.086876e-01
## contr_shape        2.233892e-07 1.046972e-01 0.108687609           NA
## contr_scale        2.760158e-06 3.522723e-01 0.162092247 0.000000e+00
## contr_thresh       6.823955e-05 1.704031e-01 0.040185855 0.000000e+00
## contr_pcorr        8.492351e-04 1.282119e-02 0.001067264 2.692248e-06
## Vocab_num_corr     4.955525e-06 3.542456e-01 0.984064358 6.592867e-01
## Vocab_score        1.700044e-06 3.644969e-01 0.941099281 9.273663e-01
## Mental_rot_score   1.170175e-12 1.292572e-01 0.885298506 1.204888e-07
## Mental_rot_both    0.000000e+00 1.932456e-02 0.959205494 1.472415e-06
## Feminine_hobbies   8.418793e-03 2.731488e-02 0.931805265 5.418875e-02
## Masculine_hobbies  6.624560e-04 5.237597e-01 0.719134620 2.246188e-03
## log_motion_sens    0.000000e+00 0.000000e+00 0.986853675 2.513610e-08
## log_contrast_sens  9.254835e-05 8.848639e-02 0.083918357 0.000000e+00
##                    contr_scale contr_thresh  contr_pcorr Vocab_num_corr
## Participant       1.312668e-01 7.101153e-01 3.985817e-01   5.766478e-02
## motion_run        8.534305e-01 8.239839e-01 6.648374e-01   6.538569e-01
## motion_shape      1.280492e-09 2.321006e-07 1.252821e-04   5.336818e-05
## motion_scale      3.700522e-07 1.412737e-05 4.101512e-04   5.433624e-06
## motion_thresh     2.760158e-06 6.823955e-05 8.492351e-04   4.955525e-06
## motion_pcorr      3.522723e-01 1.704031e-01 1.282119e-02   3.542456e-01
## contr_run         1.620922e-01 4.018586e-02 1.067264e-03   9.840644e-01
## contr_shape       0.000000e+00 0.000000e+00 2.692248e-06   6.592867e-01
## contr_scale                 NA 0.000000e+00 0.000000e+00   5.789904e-01
## contr_thresh      0.000000e+00           NA 1.516875e-08   1.142619e-01
## contr_pcorr       0.000000e+00 1.516875e-08           NA   5.163185e-02
## Vocab_num_corr    5.789904e-01 1.142619e-01 5.163185e-02             NA
## Vocab_score       8.678571e-01 5.917504e-01 1.661069e-02   0.000000e+00
## Mental_rot_score  9.240870e-07 4.121450e-10 3.920185e-03   7.548704e-01
## Mental_rot_both   3.323636e-05 5.787163e-09 1.931131e-05   7.489124e-03
## Feminine_hobbies  2.980942e-01 7.299080e-01 7.160670e-01   3.737808e-03
## Masculine_hobbies 4.305783e-04 2.588919e-04 2.675741e-01   1.822003e-03
## log_motion_sens   6.052115e-07 1.703271e-05 1.101987e-04   8.680844e-07
## log_contrast_sens 0.000000e+00 0.000000e+00 6.808565e-08   4.720879e-02
##                    Vocab_score Mental_rot_score Mental_rot_both
## Participant       1.413244e-01     4.400594e-05    2.835897e-07
## motion_run        7.399363e-01     9.173650e-01    9.657268e-01
## motion_shape      6.866417e-05     1.264544e-10    1.487255e-12
## motion_scale      2.488616e-06     9.139356e-13    0.000000e+00
## motion_thresh     1.700044e-06     1.170175e-12    0.000000e+00
## motion_pcorr      3.644969e-01     1.292572e-01    1.932456e-02
## contr_run         9.410993e-01     8.852985e-01    9.592055e-01
## contr_shape       9.273663e-01     1.204888e-07    1.472415e-06
## contr_scale       8.678571e-01     9.240870e-07    3.323636e-05
## contr_thresh      5.917504e-01     4.121450e-10    5.787163e-09
## contr_pcorr       1.661069e-02     3.920185e-03    1.931131e-05
## Vocab_num_corr    0.000000e+00     7.548704e-01    7.489124e-03
## Vocab_score                 NA     7.288137e-02    1.704256e-06
## Mental_rot_score  7.288137e-02               NA    0.000000e+00
## Mental_rot_both   1.704256e-06     0.000000e+00              NA
## Feminine_hobbies  4.967831e-04     0.000000e+00    0.000000e+00
## Masculine_hobbies 1.633742e-01     9.128396e-02    8.926619e-02
## log_motion_sens   4.441929e-07     2.997602e-13    0.000000e+00
## log_contrast_sens 4.149986e-01     4.018186e-11    2.394405e-09
##                   Feminine_hobbies Masculine_hobbies log_motion_sens
## Participant           0.0000000000      3.685940e-14    8.726935e-01
## motion_run            0.6179171552      4.302843e-01    8.687924e-04
## motion_shape          0.0064206108      4.387775e-03    0.000000e+00
## motion_scale          0.0071266813      3.667585e-04    0.000000e+00
## motion_thresh         0.0084187927      6.624560e-04    0.000000e+00
## motion_pcorr          0.0273148760      5.237597e-01    0.000000e+00
## contr_run             0.9318052649      7.191346e-01    9.868537e-01
## contr_shape           0.0541887496      2.246188e-03    2.513610e-08
## contr_scale           0.2980942042      4.305783e-04    6.052115e-07
## contr_thresh          0.7299080030      2.588919e-04    1.703271e-05
## contr_pcorr           0.7160670153      2.675741e-01    1.101987e-04
## Vocab_num_corr        0.0037378082      1.822003e-03    8.680844e-07
## Vocab_score           0.0004967831      1.633742e-01    4.441929e-07
## Mental_rot_score      0.0000000000      9.128396e-02    2.997602e-13
## Mental_rot_both       0.0000000000      8.926619e-02    0.000000e+00
## Feminine_hobbies                NA      0.000000e+00    6.642189e-04
## Masculine_hobbies     0.0000000000                NA    1.996822e-04
## log_motion_sens       0.0006642189      1.996822e-04              NA
## log_contrast_sens     0.5727415687      4.574207e-04    1.845379e-05
##                   log_contrast_sens
## Participant            9.120809e-01
## motion_run             8.424144e-01
## motion_shape           2.727610e-07
## motion_scale           1.945740e-05
## motion_thresh          9.254835e-05
## motion_pcorr           8.848639e-02
## contr_run              8.391836e-02
## contr_shape            0.000000e+00
## contr_scale            0.000000e+00
## contr_thresh           0.000000e+00
## contr_pcorr            6.808565e-08
## Vocab_num_corr         4.720879e-02
## Vocab_score            4.149986e-01
## Mental_rot_score       4.018186e-11
## Mental_rot_both        2.394405e-09
## Feminine_hobbies       5.727416e-01
## Masculine_hobbies      4.574207e-04
## log_motion_sens        1.845379e-05
## log_contrast_sens                NA
# Get some colors
col <- colorRampPalette(c("blue", "white", "red"))(20)
heatmap(x = corr_F$r, col = col, symm = TRUE)

Males

Select the males and focus on the numeric scores.

df_complete_M <- df_corr %>%
  dplyr::filter(., Sex == 'Males') 

df_corr_m <- df_complete_M %>%
  dplyr::select(., -Sex)

corr_M <- Hmisc::rcorr(as.matrix(df_corr_m), type = c("pearson"))

Coefficients

corr_M$r
##                    Participant   motion_run motion_shape motion_scale
## Participant        1.000000000  0.018619766  -0.34148409  -0.23014073
## motion_run         0.018619766  1.000000000  -0.13453633  -0.12300717
## motion_shape      -0.341484093 -0.134536331   1.00000000   0.95185407
## motion_scale      -0.230140732 -0.123007168   0.95185407   1.00000000
## motion_thresh     -0.196502162 -0.118882943   0.92090807   0.99555511
## motion_pcorr      -0.063065496  0.065951639   0.02302309   0.04286434
## contr_run          0.002993172 -0.005218401   0.01707556   0.02224089
## contr_shape       -0.076948641 -0.026080510   0.12659673   0.09128008
## contr_scale       -0.090498784 -0.021008599   0.11305225   0.07728798
## contr_thresh      -0.027992458 -0.021019034   0.11018185   0.08412117
## contr_pcorr       -0.198325039  0.002347590  -0.02403137  -0.04708388
## Vocab_num_corr     0.316491111  0.019522795  -0.07095277  -0.06083983
## Vocab_score        0.323602263  0.019323195  -0.16938480  -0.16153305
## Mental_rot_score  -0.220390154  0.007295151   0.12925732   0.17096057
## Mental_rot_both   -0.235036425  0.007364202   0.07680191   0.11488392
## Feminine_hobbies   0.002575847 -0.001821819  -0.06078446  -0.03421067
## Masculine_hobbies -0.249313201 -0.022218914   0.19313665   0.17655770
## log_motion_sens   -0.191892584 -0.113270943   0.91549064   0.97372432
## log_contrast_sens -0.004032652 -0.022194027   0.09538128   0.07829927
##                   motion_thresh motion_pcorr    contr_run contr_shape
## Participant         -0.19650216 -0.063065496  0.002993172 -0.07694864
## motion_run          -0.11888294  0.065951639 -0.005218401 -0.02608051
## motion_shape         0.92090807  0.023023090  0.017075558  0.12659673
## motion_scale         0.99555511  0.042864344  0.022240889  0.09128008
## motion_thresh        1.00000000  0.046861975  0.022682834  0.07868753
## motion_pcorr         0.04686198  1.000000000  0.009133272  0.04037141
## contr_run            0.02268283  0.009133272  1.000000000  0.16907927
## contr_shape          0.07868753  0.040371408  0.169079266  1.00000000
## contr_scale          0.06402963  0.027756649  0.162185482  0.95554070
## contr_thresh         0.07464460 -0.009933975  0.152389934  0.69261222
## contr_pcorr         -0.05339304  0.016759955 -0.033009105  0.26584460
## Vocab_num_corr      -0.06208200 -0.241706042 -0.002492926 -0.18178525
## Vocab_score         -0.16187988 -0.181517533 -0.001643174 -0.19112675
## Mental_rot_score     0.18269251  0.212011338  0.013716236 -0.19633200
## Mental_rot_both      0.12546068  0.200991586  0.013228038 -0.18033010
## Feminine_hobbies    -0.02835725  0.101746497  0.005873843  0.05677170
## Masculine_hobbies    0.16382530 -0.080616410  0.004335864  0.10810776
## log_motion_sens      0.97769701 -0.019617864  0.016260919  0.05239551
## log_contrast_sens    0.07130477 -0.013900206  0.147396569  0.65978333
##                   contr_scale contr_thresh contr_pcorr Vocab_num_corr
## Participant       -0.09049878 -0.027992458 -0.19832504    0.316491111
## motion_run        -0.02100860 -0.021019034  0.00234759    0.019522795
## motion_shape       0.11305225  0.110181855 -0.02403137   -0.070952774
## motion_scale       0.07728798  0.084121167 -0.04708388   -0.060839835
## motion_thresh      0.06402963  0.074644604 -0.05339304   -0.062082001
## motion_pcorr       0.02775665 -0.009933975  0.01675995   -0.241706042
## contr_run          0.16218548  0.152389934 -0.03300910   -0.002492926
## contr_shape        0.95554070  0.692612217  0.26584460   -0.181785247
## contr_scale        1.00000000  0.708190442  0.33474550   -0.176925917
## contr_thresh       0.70819044  1.000000000  0.36179469   -0.101051588
## contr_pcorr        0.33474550  0.361794694  1.00000000   -0.063316183
## Vocab_num_corr    -0.17692592 -0.101051588 -0.06331618    1.000000000
## Vocab_score       -0.18338834 -0.107915322 -0.03485298    0.965219954
## Mental_rot_score  -0.18782628 -0.179652249 -0.01881387   -0.267741315
## Mental_rot_both   -0.16282517 -0.171181373 -0.01759520   -0.221635191
## Feminine_hobbies   0.02574584  0.096083020  0.08811357   -0.190672442
## Masculine_hobbies  0.10760677  0.088798228 -0.04627471   -0.004830610
## log_motion_sens    0.03736584  0.054059329 -0.07882702   -0.040633382
## log_contrast_sens  0.66611128  0.991402571  0.33650102   -0.086765013
##                    Vocab_score Mental_rot_score Mental_rot_both
## Participant        0.323602263     -0.220390154    -0.235036425
## motion_run         0.019323195      0.007295151     0.007364202
## motion_shape      -0.169384805      0.129257321     0.076801906
## motion_scale      -0.161533045      0.170960567     0.114883923
## motion_thresh     -0.161879880      0.182692508     0.125460684
## motion_pcorr      -0.181517533      0.212011338     0.200991586
## contr_run         -0.001643174      0.013716236     0.013228038
## contr_shape       -0.191126749     -0.196332004    -0.180330101
## contr_scale       -0.183388344     -0.187826278    -0.162825167
## contr_thresh      -0.107915322     -0.179652249    -0.171181373
## contr_pcorr       -0.034852983     -0.018813867    -0.017595201
## Vocab_num_corr     0.965219954     -0.267741315    -0.221635191
## Vocab_score        1.000000000     -0.201676672    -0.139917455
## Mental_rot_score  -0.201676672      1.000000000     0.962639129
## Mental_rot_both   -0.139917455      0.962639129     1.000000000
## Feminine_hobbies  -0.130304186      0.115618787     0.197664532
## Masculine_hobbies -0.023378121     -0.054508507     0.012888564
## log_motion_sens   -0.153152450      0.177212558     0.110155777
## log_contrast_sens -0.095477418     -0.174428915    -0.160418673
##                   Feminine_hobbies Masculine_hobbies log_motion_sens
## Participant            0.002575847      -0.249313201     -0.19189258
## motion_run            -0.001821819      -0.022218914     -0.11327094
## motion_shape          -0.060784460       0.193136645      0.91549064
## motion_scale          -0.034210672       0.176557701      0.97372432
## motion_thresh         -0.028357249       0.163825303      0.97769701
## motion_pcorr           0.101746497      -0.080616410     -0.01961786
## contr_run              0.005873843       0.004335864      0.01626092
## contr_shape            0.056771696       0.108107755      0.05239551
## contr_scale            0.025745843       0.107606771      0.03736584
## contr_thresh           0.096083020       0.088798228      0.05405933
## contr_pcorr            0.088113572      -0.046274710     -0.07882702
## Vocab_num_corr        -0.190672442      -0.004830610     -0.04063338
## Vocab_score           -0.130304186      -0.023378121     -0.15315245
## Mental_rot_score       0.115618787      -0.054508507      0.17721256
## Mental_rot_both        0.197664532       0.012888564      0.11015578
## Feminine_hobbies       1.000000000       0.421870808     -0.05871657
## Masculine_hobbies      0.421870808       1.000000000      0.16098853
## log_motion_sens       -0.058716574       0.160988529      1.00000000
## log_contrast_sens      0.102375301       0.106905080      0.04954396
##                   log_contrast_sens
## Participant            -0.004032652
## motion_run             -0.022194027
## motion_shape            0.095381283
## motion_scale            0.078299269
## motion_thresh           0.071304775
## motion_pcorr           -0.013900206
## contr_run               0.147396569
## contr_shape             0.659783333
## contr_scale             0.666111278
## contr_thresh            0.991402571
## contr_pcorr             0.336501024
## Vocab_num_corr         -0.086765013
## Vocab_score            -0.095477418
## Mental_rot_score       -0.174428915
## Mental_rot_both        -0.160418673
## Feminine_hobbies        0.102375301
## Masculine_hobbies       0.106905080
## log_motion_sens         0.049543964
## log_contrast_sens       1.000000000

P values

corr_M$P
##                    Participant  motion_run motion_shape motion_scale
## Participant                 NA 0.692343273 7.327472e-14 7.164741e-07
## motion_run        6.923433e-01          NA 4.081844e-03 8.698219e-03
## motion_shape      7.327472e-14 0.004081844           NA 0.000000e+00
## motion_scale      7.164741e-07 0.008698219 0.000000e+00           NA
## motion_thresh     2.480544e-05 0.011242020 0.000000e+00 0.000000e+00
## motion_pcorr      1.797955e-01 0.160645615 6.246493e-01 3.621777e-01
## contr_run         9.492882e-01 0.911708232 7.167117e-01 6.364666e-01
## contr_shape       1.015314e-01 0.579396171 6.915840e-03 5.194041e-02
## contr_scale       5.398932e-02 0.655271327 1.595578e-02 1.000281e-01
## contr_thresh      5.519001e-01 0.655111138 1.885643e-02 7.335324e-02
## contr_pcorr       2.076801e-05 0.960215689 6.095576e-01 3.168178e-01
## Vocab_num_corr    5.083933e-12 0.678236821 1.311594e-01 1.956805e-01
## Vocab_score       1.581846e-12 0.681345377 2.885041e-04 5.501765e-04
## Mental_rot_score  2.122559e-06 0.876810794 5.813701e-03 2.525710e-04
## Mental_rot_both   4.077376e-07 0.875654190 1.021869e-01 1.431622e-02
## Feminine_hobbies  9.563511e-01 0.969120786 1.960884e-01 4.671405e-01
## Masculine_hobbies 7.334843e-08 0.636799971 3.428789e-05 1.559870e-04
## log_motion_sens   3.859275e-05 0.015751747 0.000000e+00 0.000000e+00
## log_contrast_sens 9.317142e-01 0.637177571 4.221992e-02 9.565292e-02
##                   motion_thresh motion_pcorr    contr_run  contr_shape
## Participant        2.480544e-05 1.797955e-01 0.9492881993 1.015314e-01
## motion_run         1.124202e-02 1.606456e-01 0.9117082321 5.793962e-01
## motion_shape       0.000000e+00 6.246493e-01 0.7167116634 6.915840e-03
## motion_scale       0.000000e+00 3.621777e-01 0.6364666157 5.194041e-02
## motion_thresh                NA 3.191064e-01 0.6297782124 9.401429e-02
## motion_pcorr       3.191064e-01           NA 0.8461189608 3.907913e-01
## contr_run          6.297782e-01 8.461190e-01           NA 2.960021e-04
## contr_shape        9.401429e-02 3.907913e-01 0.0002960021           NA
## contr_scale        1.732188e-01 5.552565e-01 0.0005220119 0.000000e+00
## contr_thresh       1.122174e-01 8.328189e-01 0.0011255444 0.000000e+00
## contr_pcorr        2.562355e-01 7.217286e-01 0.4829371660 8.785748e-09
## Vocab_num_corr     1.866930e-01 1.854130e-07 0.9577549214 9.812909e-05
## Vocab_score        5.350332e-04 1.005179e-04 0.9721474677 4.149193e-05
## Mental_rot_score   9.042480e-05 5.193040e-06 0.7706967448 2.521813e-05
## Mental_rot_both    7.440920e-03 1.596840e-05 0.7786423376 1.117882e-04
## Feminine_hobbies   5.467274e-01 3.018974e-02 0.9006726638 2.273208e-01
## Masculine_hobbies  4.570281e-04 8.620338e-02 0.9265937969 2.122896e-02
## log_motion_sens    0.000000e+00 6.767581e-01 0.7296857692 2.652392e-01
## log_contrast_sens  1.292532e-01 7.677087e-01 0.0016373005 0.000000e+00
##                    contr_scale contr_thresh  contr_pcorr Vocab_num_corr
## Participant       5.398932e-02 5.519001e-01 2.076801e-05   5.083933e-12
## motion_run        6.552713e-01 6.551111e-01 9.602157e-01   6.782368e-01
## motion_shape      1.595578e-02 1.885643e-02 6.095576e-01   1.311594e-01
## motion_scale      1.000281e-01 7.335324e-02 3.168178e-01   1.956805e-01
## motion_thresh     1.732188e-01 1.122174e-01 2.562355e-01   1.866930e-01
## motion_pcorr      5.552565e-01 8.328189e-01 7.217286e-01   1.854130e-07
## contr_run         5.220119e-04 1.125544e-03 4.829372e-01   9.577549e-01
## contr_shape       0.000000e+00 0.000000e+00 8.785748e-09   9.812909e-05
## contr_scale                 NA 0.000000e+00 2.384759e-13   1.510408e-04
## contr_thresh      0.000000e+00           NA 1.776357e-15   3.134137e-02
## contr_pcorr       2.384759e-13 1.776357e-15           NA   1.780679e-01
## Vocab_num_corr    1.510408e-04 3.134137e-02 1.780679e-01             NA
## Vocab_score       8.490568e-05 2.146169e-02 4.588148e-01   0.000000e+00
## Mental_rot_score  5.651015e-05 1.187440e-04 6.893020e-01   6.822022e-09
## Mental_rot_both   4.957032e-04 2.478838e-04 7.084778e-01   1.852711e-06
## Feminine_hobbies  5.842742e-01 4.072095e-02 6.066427e-02   4.330786e-05
## Masculine_hobbies 2.183947e-02 5.868197e-02 3.252154e-01   9.182455e-01
## log_motion_sens   4.270518e-01 2.503407e-01 9.343110e-02   3.877216e-01
## log_contrast_sens 0.000000e+00 0.000000e+00 1.758593e-13   6.473060e-02
##                    Vocab_score Mental_rot_score Mental_rot_both
## Participant       1.581846e-12     2.122559e-06    4.077376e-07
## motion_run        6.813454e-01     8.768108e-01    8.756542e-01
## motion_shape      2.885041e-04     5.813701e-03    1.021869e-01
## motion_scale      5.501765e-04     2.525710e-04    1.431622e-02
## motion_thresh     5.350332e-04     9.042480e-05    7.440920e-03
## motion_pcorr      1.005179e-04     5.193040e-06    1.596840e-05
## contr_run         9.721475e-01     7.706967e-01    7.786423e-01
## contr_shape       4.149193e-05     2.521813e-05    1.117882e-04
## contr_scale       8.490568e-05     5.651015e-05    4.957032e-04
## contr_thresh      2.146169e-02     1.187440e-04    2.478838e-04
## contr_pcorr       4.588148e-01     6.893020e-01    7.084778e-01
## Vocab_num_corr    0.000000e+00     6.822022e-09    1.852711e-06
## Vocab_score                 NA     1.491742e-05    2.810385e-03
## Mental_rot_score  1.491742e-05               NA    0.000000e+00
## Mental_rot_both   2.810385e-03     0.000000e+00              NA
## Feminine_hobbies  5.425227e-03     1.370126e-02    2.215297e-05
## Masculine_hobbies 6.193169e-01     2.464204e-01    7.841811e-01
## log_motion_sens   1.061876e-03     1.472927e-04    1.888477e-02
## log_contrast_sens 4.201186e-02     1.876923e-04    6.015670e-04
##                   Feminine_hobbies Masculine_hobbies log_motion_sens
## Participant           9.563511e-01      7.334843e-08    3.859275e-05
## motion_run            9.691208e-01      6.368000e-01    1.575175e-02
## motion_shape          1.960884e-01      3.428789e-05    0.000000e+00
## motion_scale          4.671405e-01      1.559870e-04    0.000000e+00
## motion_thresh         5.467274e-01      4.570281e-04    0.000000e+00
## motion_pcorr          3.018974e-02      8.620338e-02    6.767581e-01
## contr_run             9.006727e-01      9.265938e-01    7.296858e-01
## contr_shape           2.273208e-01      2.122896e-02    2.652392e-01
## contr_scale           5.842742e-01      2.183947e-02    4.270518e-01
## contr_thresh          4.072095e-02      5.868197e-02    2.503407e-01
## contr_pcorr           6.066427e-02      3.252154e-01    9.343110e-02
## Vocab_num_corr        4.330786e-05      9.182455e-01    3.877216e-01
## Vocab_score           5.425227e-03      6.193169e-01    1.061876e-03
## Mental_rot_score      1.370126e-02      2.464204e-01    1.472927e-04
## Mental_rot_both       2.215297e-05      7.841811e-01    1.888477e-02
## Feminine_hobbies                NA      0.000000e+00    2.117679e-01
## Masculine_hobbies     0.000000e+00                NA    5.747557e-04
## log_motion_sens       2.117679e-01      5.747557e-04              NA
## log_contrast_sens     2.917908e-02      2.272012e-02    2.921652e-01
##                   log_contrast_sens
## Participant            9.317142e-01
## motion_run             6.371776e-01
## motion_shape           4.221992e-02
## motion_scale           9.565292e-02
## motion_thresh          1.292532e-01
## motion_pcorr           7.677087e-01
## contr_run              1.637300e-03
## contr_shape            0.000000e+00
## contr_scale            0.000000e+00
## contr_thresh           0.000000e+00
## contr_pcorr            1.758593e-13
## Vocab_num_corr         6.473060e-02
## Vocab_score            4.201186e-02
## Mental_rot_score       1.876923e-04
## Mental_rot_both        6.015670e-04
## Feminine_hobbies       2.917908e-02
## Masculine_hobbies      2.272012e-02
## log_motion_sens        2.921652e-01
## log_contrast_sens                NA
# Get some colors
col <- colorRampPalette(c("blue", "white", "red"))(20)
heatmap(x = corr_M$r, col = col, symm = TRUE)

Visualization

sex_diff_scatter <-
  function(df,
           x_var,
           y_var,
           x_rev = FALSE,
           y_rev = FALSE,
           an1 = "",
           an2 = "",
           anx = NULL,
           any = NULL,
           square_axis = FALSE) {
    require(tidyverse)
    require(ggExtra)
    
    x_var_s <- sym(x_var)
    y_var_s <- sym(y_var)
    
    p <- ggplot(df) +
      aes(
        x = !!x_var_s,
        y = !!y_var_s,
        group = Sex,
        color = Sex
      ) +
      geom_point() +
      xlab(x_var) +
      ylab(y_var) +
      stat_smooth(method = "lm", na.rm = TRUE) +
      theme_classic2() +
      theme(legend.position = "bottom",
            legend.title = element_blank()) +
      annotate(
        "text",
        x = anx,
        y = any,
        label = c(an1, an2),
        color = c('red', 'darkturquoise')
      )
    
    if (square_axis)
    {
      p + coord_fixed()
    }
    
    if (stringr::str_detect(x_var, 'hobbies')) {
      p <- p + xlim(1, 5)
    }
    if (stringr::str_detect(y_var, 'hobbies')) {
      p <- p + ylim(1, 5)
    }
    
    # Reverse scale for threshold measures?
    if (x_rev)
      p <- p + scale_x_reverse()
    if (y_rev)
      p <- p + scale_y_reverse()
    
    p1 <- ggExtra::ggMarginal(
      p,
      type = "density",
      margins = "both",
      xparams = list(bins = 10),
      yparams = list(bins = 10),
      groupFill = TRUE
    )
    p1
  }
sex_diff_corr_summ <- function(x_var, y_var, print_table = TRUE) {
  require(tidyverse) # for %>%
  
  corr_all_df <- tibble::tibble(
    cor_coef = corr_all$r[x_var, y_var],
    p_val = corr_all$P[x_var, y_var],
    n =  corr_all$n[x_var, y_var],
    pop = "Both"
  )
  males_df <- tibble::tibble(
    cor_coef = corr_M$r[x_var, y_var],
    p_val = corr_M$P[x_var, y_var],
    n =  corr_M$n[x_var, y_var],
    pop = "Males"
  )
  
  females_df <- tibble::tibble(
    cor_coef = corr_F$r[x_var, y_var],
    p_val = corr_F$P[x_var, y_var],
    n =  corr_F$n[x_var, y_var],
    pop = "Females"
  )
  
  df <- rbind(corr_all_df, males_df, females_df)
  
  df <- df %>%
    mutate(., stars = if_else(p_val < .005, "***",
                              if_else(p_val < .01, "**",
                                      if_else(p_val < .05, "*", " ns"))))
    
  
  if (print_table) {
  kableExtra::kable(df, format = 'html') %>%
    kableExtra::kable_styling()    
  } else {
    df
  }
}

Motion & Contrast

corr_df <- sex_diff_corr_summ("log_motion_sens",
                   "log_contrast_sens", print_table = FALSE)

sex_diff_scatter(
  df_corr,
  "log_motion_sens",
  "log_contrast_sens",
  x_rev = TRUE,
  y_rev = TRUE,
  # "r=0.22*",
  # "r=0.54***",
  paste0("r = ", format(corr_df$cor_coef[3], digits = 2, nsmall = 2), corr_df$stars[3]),
  paste0("r = ", format(corr_df$cor_coef[2], digits = 2, nsmall = 2), corr_df$stars[2]),
  c(-2.9, -2.9),
  c(-1.13, -1.06)
)
## `geom_smooth()` using formula 'y ~ x'
## Warning: Ignoring unknown parameters: bins

## Warning: Ignoring unknown parameters: bins

## Warning: Ignoring unknown parameters: bins

## Warning: Ignoring unknown parameters: bins
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 23 rows containing missing values (geom_point).

sex_diff_corr_summ("log_motion_sens",
                   "log_contrast_sens")
cor_coef p_val n pop stars
0.1453959 0.0000000 1907 Both ***
0.0495440 0.2921652 454 Males ns
0.1120984 0.0000185 1453 Females ***

Linear model

motion_contr_lm <- lm(formula = log_contrast_sens ~ log_motion_sens*Sex, data = df_corr)
summary(motion_contr_lm)
## 
## Call:
## lm(formula = log_contrast_sens ~ log_motion_sens * Sex, data = df_corr)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.35757 -0.16221 -0.05791  0.07184  0.87148 
## 
## Coefficients:
##                          Estimate Std. Error t value Pr(>|t|)    
## (Intercept)              -1.44776    0.06211 -23.310  < 2e-16 ***
## log_motion_sens           0.12348    0.02692   4.587 4.79e-06 ***
## SexMales                 -0.27221    0.13745  -1.980   0.0478 *  
## log_motion_sens:SexMales -0.08506    0.05593  -1.521   0.1285    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.2328 on 1903 degrees of freedom
##   (23 observations deleted due to missingness)
## Multiple R-squared:  0.03407,    Adjusted R-squared:  0.03255 
## F-statistic: 22.37 on 3 and 1903 DF,  p-value: 3.096e-14
anova(motion_contr_lm)
## Analysis of Variance Table
## 
## Response: log_contrast_sens
##                       Df  Sum Sq Mean Sq F value    Pr(>F)    
## log_motion_sens        1   2.257 2.25713 41.6482 1.383e-10 ***
## Sex                    1   1.255 1.25504 23.1577 1.610e-06 ***
## log_motion_sens:Sex    1   0.125 0.12534  2.3128    0.1285    
## Residuals           1903 103.133 0.05420                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Motion & Mental rotation

corr_df <- sex_diff_corr_summ("log_motion_sens", 
                   "Mental_rot_score", print_table = FALSE)

sex_diff_scatter(
  df_corr,
  "log_motion_sens",
  "Mental_rot_score",
  x_rev = TRUE,
  y_rev = FALSE,
  # "r = 0.31**",
  paste0("r = ", format(corr_df$cor_coef[3], digits = 2, nsmall = 2), corr_df$stars[3]),
  paste0("r = ", format(corr_df$cor_coef[2], digits = 2, nsmall = 2), corr_df$stars[2]),
  # "r = 0.09",
  c(-2.75),
  c(17, 15)
)
## `geom_smooth()` using formula 'y ~ x'
## Warning: Ignoring unknown parameters: bins

## Warning: Ignoring unknown parameters: bins

## Warning: Ignoring unknown parameters: bins

## Warning: Ignoring unknown parameters: bins
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 27 rows containing missing values (geom_point).

sex_diff_corr_summ("log_motion_sens", "Mental_rot_score")
cor_coef p_val n pop stars
-0.1644018 0.0000000 1903 Both ***
0.1772126 0.0001473 454 Males ***
-0.1900451 0.0000000 1449 Females ***

Motion & vocabulary

corr_df <- sex_diff_corr_summ("log_motion_sens", "Vocab_score",
                   print_table = FALSE)

sex_diff_scatter(
  df_corr,
  "log_motion_sens",
  "Vocab_score",
  x_rev = TRUE,
  y_rev = FALSE,
  # "r = 0.18",
  # "r=0.22",
  paste0("r = ", format(corr_df$cor_coef[3], digits = 2, nsmall = 2), corr_df$stars[3]),
  paste0("r = ", format(corr_df$cor_coef[2], digits = 2, nsmall = 2), corr_df$stars[2]),
  c(-1.75),
  c(21, 19)
)
## `geom_smooth()` using formula 'y ~ x'
## Warning: Ignoring unknown parameters: bins

## Warning: Ignoring unknown parameters: bins

## Warning: Ignoring unknown parameters: bins

## Warning: Ignoring unknown parameters: bins
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 27 rows containing missing values (geom_point).

sex_diff_corr_summ("log_motion_sens", "Vocab_score")
cor_coef p_val n pop stars
-0.1522198 0.0000000 1903 Both ***
-0.1531524 0.0010619 454 Males ***
-0.1321700 0.0000004 1449 Females ***

Motion & Feminine hobbies

corr_df <- sex_diff_corr_summ("log_motion_sens", "Feminine_hobbies",
                   print_table = FALSE)

sex_diff_scatter(
  df_corr,
  "log_motion_sens",
  "Feminine_hobbies",
  x_rev = TRUE,
  y_rev = FALSE,
  # "r = 0.18",
  # "r=0.22",
  paste0("r = ", format(corr_df$cor_coef[3], digits = 2, nsmall = 2), corr_df$stars[3]),
  paste0("r = ", format(corr_df$cor_coef[2], digits = 2, nsmall = 2), corr_df$stars[2]),
  c(-1.75),
  c(2.5, 2.2)
)
## `geom_smooth()` using formula 'y ~ x'
## Warning: Ignoring unknown parameters: bins

## Warning: Ignoring unknown parameters: bins

## Warning: Ignoring unknown parameters: bins

## Warning: Ignoring unknown parameters: bins
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 27 rows containing missing values (geom_point).

sex_diff_corr_summ("log_motion_sens", "Feminine_hobbies")
cor_coef p_val n pop stars
0.1799661 0.0000000 1903 Both ***
-0.0587166 0.2117679 454 Males ns
0.0893209 0.0006642 1449 Females ***

Motion & Masculine hobbies

corr_df <- sex_diff_corr_summ("log_motion_sens", "Masculine_hobbies",
                   print_table = FALSE)

sex_diff_scatter(
  df_corr,
  "log_motion_sens",
  "Masculine_hobbies",
  x_rev = TRUE,
  y_rev = FALSE,
  # "r = 0.18",
  # "r=0.22",
  paste0("r = ", format(corr_df$cor_coef[3], digits = 2, nsmall = 2), corr_df$stars[3]),
  paste0("r = ", format(corr_df$cor_coef[2], digits = 2, nsmall = 2), corr_df$stars[2]),
  c(-1.75),
  c(4.5, 4.2)
)
## `geom_smooth()` using formula 'y ~ x'
## Warning: Ignoring unknown parameters: bins

## Warning: Ignoring unknown parameters: bins

## Warning: Ignoring unknown parameters: bins

## Warning: Ignoring unknown parameters: bins
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 27 rows containing missing values (geom_point).

sex_diff_corr_summ("log_motion_sens", "Masculine_hobbies")
cor_coef p_val n pop stars
-0.2217621 0.0000000 1903 Both ***
0.1609885 0.0005748 454 Males ***
-0.0975614 0.0001997 1449 Females ***

Contrast and Mental rotation

corr_df <- sex_diff_corr_summ("log_contrast_sens", "Mental_rot_score",
                   print_table = FALSE)

sex_diff_scatter(
  df_corr,
  "log_contrast_sens",
  "Mental_rot_score",
  x_rev = TRUE,
  y_rev = FALSE,
  # "r = -0.19*",
  # "r = 0.12",
  paste0("r = ", format(corr_df$cor_coef[3], digits = 2, nsmall = 2), corr_df$stars[3]),
  paste0("r = ", format(corr_df$cor_coef[2], digits = 2, nsmall = 2), corr_df$stars[2]),
  c(-1.0),
  c(36, 34)
)
## `geom_smooth()` using formula 'y ~ x'
## Warning: Ignoring unknown parameters: bins

## Warning: Ignoring unknown parameters: bins

## Warning: Ignoring unknown parameters: bins

## Warning: Ignoring unknown parameters: bins
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 20 rows containing missing values (geom_point).

sex_diff_corr_summ("log_contrast_sens", "Mental_rot_score")
cor_coef p_val n pop stars
-0.1957470 0.0000000 1910 Both ***
-0.1744289 0.0001877 454 Males ***
-0.1719140 0.0000000 1456 Females ***

Contrast and vocabulary

corr_df <- sex_diff_corr_summ("log_contrast_sens", "Vocab_score",
                   print_table = FALSE)

sex_diff_scatter(
  df_corr,
  "log_contrast_sens",
  "Vocab_score",
  x_rev = TRUE,
  y_rev = FALSE,
  # "r = -0.19*",
  # "r = 0.12",
  paste0("r = ", format(corr_df$cor_coef[3], digits = 2, nsmall = 2), corr_df$stars[3]),
  paste0("r = ", format(corr_df$cor_coef[2], digits = 2, nsmall = 2), corr_df$stars[2]),
  c(-1.5),
  c(28, 25)
)
## `geom_smooth()` using formula 'y ~ x'
## Warning: Ignoring unknown parameters: bins

## Warning: Ignoring unknown parameters: bins

## Warning: Ignoring unknown parameters: bins

## Warning: Ignoring unknown parameters: bins
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 20 rows containing missing values (geom_point).

sex_diff_corr_summ("log_contrast_sens", "Vocab_score")
cor_coef p_val n pop stars
-0.0119210 0.6025997 1910 Both ns
-0.0954774 0.0420119 454 Males
0.0213781 0.4149986 1456 Females ns

Contrast & Feminine hobbies

corr_df <- sex_diff_corr_summ("log_contrast_sens", "Feminine_hobbies",
                              print_table = FALSE)

sex_diff_scatter(
  df_corr,
  "log_contrast_sens",
  "Feminine_hobbies",
  x_rev = TRUE,
  y_rev = FALSE,
  # "r = -0.19*",
  # "r = 0.26",
  paste0("r = ", format(corr_df$cor_coef[3], digits = 2, nsmall = 2), corr_df$stars[3]),
  paste0("r = ", format(corr_df$cor_coef[2], digits = 2, nsmall = 2), corr_df$stars[2]),
  c(-1.3),
  c(2.5, 2.2)
)
## `geom_smooth()` using formula 'y ~ x'
## Warning: Ignoring unknown parameters: bins

## Warning: Ignoring unknown parameters: bins

## Warning: Ignoring unknown parameters: bins

## Warning: Ignoring unknown parameters: bins
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 20 rows containing missing values (geom_point).

sex_diff_corr_summ("log_contrast_sens", "Feminine_hobbies")
cor_coef p_val n pop stars
0.0867421 0.0001473 1910 Both ***
0.1023753 0.0291791 454 Males
0.0147932 0.5727416 1456 Females ns

Contrast & Masculine hobbies

corr_df <- sex_diff_corr_summ("log_contrast_sens", "Masculine_hobbies",
                              print_table = FALSE)

sex_diff_scatter(
  df_corr,
  "log_contrast_sens",
  "Masculine_hobbies",
  x_rev = TRUE,
  y_rev = FALSE,
  # "r = -0.19*",
  # "r = 0.26",
  paste0("r = ", format(corr_df$cor_coef[3], digits = 2, nsmall = 2), corr_df$stars[3]),
  paste0("r = ", format(corr_df$cor_coef[2], digits = 2, nsmall = 2), corr_df$stars[2]),
  c(-1.3),
  c(4.5, 4.2)
)
## `geom_smooth()` using formula 'y ~ x'
## Warning: Ignoring unknown parameters: bins

## Warning: Ignoring unknown parameters: bins

## Warning: Ignoring unknown parameters: bins

## Warning: Ignoring unknown parameters: bins
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 20 rows containing missing values (geom_point).

sex_diff_corr_summ("log_contrast_sens", "Masculine_hobbies")
cor_coef p_val n pop stars
-0.1312884 0.0000000 1910 Both ***
0.1069051 0.0227201 454 Males
-0.0917286 0.0004574 1456 Females ***

Masculine and Feminine hobbies

corr_df <- sex_diff_corr_summ("Masculine_hobbies", "Feminine_hobbies", print_table = FALSE)

sex_diff_scatter(df_corr, 
                x_var = "Masculine_hobbies",
                y_var = "Feminine_hobbies",
                x_rev = FALSE,
                y_rev = FALSE,
  paste0("r = ", format(corr_df$cor_coef[3], digits = 2, nsmall = 2), corr_df$stars[3]),
  paste0("r = ", format(corr_df$cor_coef[2], digits = 2, nsmall = 2), corr_df$stars[2]),
                anx = 3,
                any = c(1.9, 1.6))
## `geom_smooth()` using formula 'y ~ x'
## Warning: Ignoring unknown parameters: bins

## Warning: Ignoring unknown parameters: bins

## Warning: Ignoring unknown parameters: bins

## Warning: Ignoring unknown parameters: bins
## `geom_smooth()` using formula 'y ~ x'
## Warning: Removed 12 rows containing missing values (geom_point).

sex_diff_corr_summ("Masculine_hobbies", "Feminine_hobbies")
cor_coef p_val n pop stars
0.1516326 0 1918 Both ***
0.4218708 0 454 Males ***
0.4957801 0 1464 Females ***